using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using System.Windows.Media;
using System.IO;



namespace Docentric.Examples.Browser
{
	#region BoolInversionConverter
	public class BoolInversionConverter : IValueConverter
	{
		#region IValueConverter Members
		// Convert
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			return !(bool)value;
		}


		// ConvertBack
		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			return !(bool)value;
		}
		#endregion
	}
	#endregion



	public class NBoolToBoolConverter : IValueConverter
	{
		#region IValueConverter Members
		// Convert
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			return (bool)(bool?)value;
		}


		// ConvertBack
		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			return (bool?)(bool)value;
		}
		#endregion
	}




	public class BoolToVisibilityConverter : IValueConverter
	{
		// Fields
		private bool _InvertWithNotOperator;



		#region IValueConverter Members
		// Convert
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			bool bValue = (bool)value;

			if (_InvertWithNotOperator == true)
				bValue = !bValue;

			return bValue == true ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
		}


		// ConvertBack
		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			bool result = (System.Windows.Visibility)value == System.Windows.Visibility.Visible ? true : false;

			if (_InvertWithNotOperator == true)
				return !result;
			else
				return result;
		}
		#endregion



		#region Properties
		// InvertWithNotOperator
		public bool InvertWithNotOperator
		{
			get
			{
				return _InvertWithNotOperator;
			}
			set
			{
				_InvertWithNotOperator = value;
			}
		}
		#endregion
	}
}
